package com.accp.demo.service.stock;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.accp.demo.mapper.stock.IStockReportoryDetailMapper;
import com.accp.demo.pojo.PageBean;
import com.accp.demo.pojo.stock.StockReportoryDetail;

@Service
public class StockReportoryDetailService {
	
	@Autowired
	private IStockReportoryDetailMapper iStockReportoryDetailMapper;
	
	/**
	 * 出入库明细，库存台账明细新增
	 * @param stockReportoryDetail 
	 */
	public void insert(StockReportoryDetail stockReportoryDetail){
		iStockReportoryDetailMapper.insert(stockReportoryDetail);
	}

	/**
	 * 逻辑删除出入库明细，库存台账明细表
	 * @param infoId 主键编号
	 */
	public void logicDelete(int infoId){
		iStockReportoryDetailMapper.delete(infoId);
	}
	
	/**
	 * 更新出入库明细，库存台账明细表
	 * @param stockReportoryDetail
	 */
	public void update(StockReportoryDetail stockReportoryDetail){
		iStockReportoryDetailMapper.update(stockReportoryDetail);
	}
	
	public PageBean findByPage(Map<String,Object> map){
		int currentPage=Integer.valueOf(String.valueOf(map.get("currentPage")));
		int pageSize=Integer.valueOf(String.valueOf(map.get("pageSize")));
		int count=iStockReportoryDetailMapper.count();
		//将currentPage修改为数据库所需的当前页数参数
		map.put("currentPage",(currentPage-1)*pageSize);
		System.out.println("我现在准备查询数据了!!!  查的是第"+currentPage+"页"+"，这一页有"+pageSize+"条记录！");
		List<StockReportoryDetail> detail=iStockReportoryDetailMapper.findByMap(map);
		System.out.println("detail:"+detail);
		
		PageBean pageBean=new PageBean(pageSize, count, currentPage, detail);
		
		return pageBean;
}
	
}
